<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>成果下载 | {$system_name}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="{_ADMIN_STATIC_}/i/favicon.png">
    <!-- <link rel="apple-touch-icon-precomposed" href="{_ADMIN_STATIC_}/i/app-icon72x72@2x.png"> -->
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/amazeui.min.css" />
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/admin.css">
    <link rel="stylesheet" href="{_ADMIN_STATIC_}/css/app.css">
    <!-- <script src="{_ADMIN_STATIC_}/js/echarts.min.js"></script> -->

</head>

<body data-type="index">
    <!-- 头部导航栏 -->
    {include file='public/header'}
    <!-- 左侧侧边栏 -->
    {include file='public/side'}
    <!-- 中间内容开始 -->

    <!-- 标题 -->
    <div class="tpl-content-page-title">
        {$system_name} -- 成果下载自定义页面
    </div>
    <!-- 面包屑导航 -->
    <ol class="am-breadcrumb">
        <li><a href="{$index_home}" class="am-icon-home">成果管理首页</a></li>
        <li><a href="{:url('AchievementManage/download')}" class="am-icon-home">成果管理下载页面</a></li>
        <li>成果下载自定义</a></li>
    </ol>
    <!-- 提示信息 -->
    <!-- <div class="tpl-content-scope">
        <div class="note note-info">
            <h3> 成果下载起始页
                <span class="close" data-close="note"></span>
            </h3>
            <p>该页面涵盖了成果的所有信息以及功能</p>
            <p><span class="label label-danger">提示:</span>
                当前页面为成果下载的主要页面
            </p>
        </div>
    </div> -->

    <!-- 内容 -->
    <div class="tpl-portlet-components">


        <div class="row">
            <table class="am-table am-table-striped am-table-hover table-main">
                <thead>
                    <tr>
                        <th>#</th>
                        {volist name="table_content['names']" id="row"}
                        <th>{$row}</th>
                        {/volist}
                    </tr>
                </thead>
                <tbody>
                    {volist name="classify_table_other_info" id="classify_table_row"}
                    <tr>
                        <td><input type="checkbox" value="{$classify_table_row.id}" onclick="cbox_select(this)"></td>
                        {volist name="table_content['cols']" id="table_content_cols" key="i"}
                        {if
                        condition="$classify_type_list[$table_content.selects[$i-1]-1]['name'] ==
                        '时间'"}
                        <td>{$classify_table_row[$table_content_cols] | date="Y-m-d"} </td>
                        {else /}
                        {if
                        condition="$classify_type_list[$table_content.selects[$i-1]-1]['name'] ==
                        '数值'"}
                        <td>{$classify_table_row[$table_content_cols] / 100 } </td>
                        {else /}
                        <td>{$classify_table_row[$table_content_cols]} </td>
                        {/if}
                        {/if}
                        {/volist}
                    </tr>
                    {/volist}

                </tbody>
            </table>

        </div>

        <div class="row">
            <div class="am-form-group">
                <div class="am-u-sm-3 am-u-sm-push-3">
                    <button type="button" class="am-btn am-btn-primary" onclick="download()">点击下载</button>
                </div>
            </div>
        </div>

    </div>


    <!-- 中间内容结束 -->
    <!-- 底部 -->
    <!-- {include file="public/footer"} -->

    <script src="{_ADMIN_STATIC_}/lib/jquery/jquery.js"></script>
    <script src="{_ADMIN_STATIC_}/js/amazeui.min.js"></script>
    <script src="{_ADMIN_STATIC_}/js/app.js"></script>
    <script src="{_ADMIN_STATIC_}/lib/layer/layer.js"></script>
    <script>

        var ids = [];

        function cbox_select(obj) {
            var cbox = $(obj);
            if (obj.checked) {
                ids.push(cbox.val());
            } else {
                var tmp_data = [];
                var n = ids.length;
                for (let index = 0; index < n; index++) {
                    var tmp_ids = ids[index];
                    if (cbox.val() != tmp_ids) {
                        tmp_data.push(tmp_ids);
                    }
                }
                ids = tmp_data;
            }
            console.log(ids)
        }

        // 点击下载
        function download() {

            var url = "{:url('AchievementManage/download_achievement')}";
            var data = {
                'cid': "{$cid}",
                'uid': "{$uid}",
                'status': 1,
                'ids': ids.toString() == '' ? '' : ids.toString()
            };
            $.ajax({
                url: url,
                data: data,
                type: "POST",
                dataType: 'JSON',
                success: function (res) {
                    if (res.code == 0) {
                        redirect_url(res.url);
                        return layer.msg(res.msg, { icon: 1, time: 900 });
                    } else {
                        return layer.msg(res.msg, { icon: 2, time: 900 });
                    }

                },
            });
        }


        // 搜索
        // function search() {
        //     var classify_id = $('#classify_id').val();
        //     var user_id = $('#user_id').val();

        //     redirect_url("{:url('AchievementManage/custom')}?cid=" + classify_id + "&uid=" + user_id);
        // }


        // 重定向
        function redirect_url(url) {
            window.location.href = url;
        }

    </script>
</body>

</html>